home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 4 / QRZ Ham Radio Callsign Database - Volume 4.iso / files / tcpip / amiga / asrc29p.lha / pppdump.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-29  |  1.8 KB  |  77 lines

  1. /*
  2.  *    PPPDUMP.C
  3.  *
  4.  *    12-89    -- Katie Stevens (dkstevens@ucdavis.edu)
  5.  *           UC Davis, Computing Services
  6.  *    PPP.08    05-90    [ks] improve tracing reports
  7.  *    PPP.09  05-90    [ks] add UPAP packet reporting
  8.  *    PPP.14    08-90    [ks] change UPAP to PAP for consistency with RFC1172
  9.  *    PPP.15    09-90    [ks] update to KA9Q NOS v900828
  10.  */
  11. #include <stdio.h>
  12. #include "global.h"
  13. #include "mbuf.h"
  14. #include "proc.h"
  15. #include "iface.h"
  16. #include "internet.h"
  17. #include "slcompre.h"
  18. #include "slip.h"
  19. #include "ppp.h"
  20. #include "trace.h"
  21.  
  22. /* dump a PPP packet */
  23. void
  24. ppp_dump(fp,bpp,unused)
  25. FILE *fp;
  26. struct mbuf **bpp;
  27. int unused;
  28. {
  29.     struct ppphdr phdr;
  30.     struct iphdr *iph;
  31.     struct mbuf *bp, *tbp;
  32.  
  33.     ntohppp(&phdr,bpp);
  34.     fprintf(fp,"PPP: len %3u     ",(PPP_HDRLEN + len_p(*bpp)));
  35.     if (phdr.addr != HDLC_ALL_ADDR)
  36.         fprintf(fp,"!invalid addr field  ");
  37.     if (phdr.control != HDLC_UI)
  38.         fprintf(fp,"!invalid ctl field  ");
  39.  
  40.     switch(phdr.type){
  41.         case PPP_IP_TYPE:
  42.             fprintf(fp,"\t\tprotocol: IP\n");
  43.             ip_dump(fp,bpp,1);
  44.             break;
  45.         case PPP_IPCP_TYPE:
  46.             fprintf(fp,"\t\tprotocol: IPCP\n");
  47.             break;
  48.         case PPP_LCP_TYPE:
  49.             fprintf(fp,"\t\tprotocol: LCP\n");
  50.             break;
  51.         case PPP_PAP_TYPE:
  52.             fprintf(fp,"\t\tprotocol: PAP\n");
  53.             break;
  54.         case PPP_COMPR_TYPE:
  55.             fprintf(fp,"\t\tprotocol: VJ Compr TCP/IP\n");
  56.             vjcomp_dump(fp,bpp,0);
  57.             break;
  58.         case PPP_UNCOMP_TYPE:
  59.             fprintf(fp,"\t\tprotocol: VJ Uncompr TCP/IP\n");
  60.             iph = (struct iphdr *)(*bpp)->data;
  61.             fprintf(fp,"VJ Uncompr TCP/IP: connection 0x%02x\n",iph->ip_protocol);
  62.             /* Get our own copy so we can mess with the data */
  63.             bp = *bpp;
  64.             tbp = copy_p(bp, len_p(bp));
  65.             free_p(bp);
  66.             *bpp = NULLBUF;
  67.             /* Restore the bytes used with Uncompressed TCP */
  68.             iph = (struct iphdr *)tbp->data;
  69.             iph->ip_protocol = TCP_PTCL;
  70.             ip_dump(fp,&tbp,1);
  71.             break;
  72.         default:
  73.             fprintf(fp,"  unknown protocol: 0x%04x\n",phdr.type);
  74.             break;
  75.     }
  76. }
  77.